pp108 : addArtifactFactoryType() Method

addArtifactFactoryType() Method


This method registers the URL of a library for Type implementation. Here, the factoryClass is extended from the ArtifactFactoryType class. The use of URL helps reuse the functionality across an application, wherever the artifactviewer with the same artifact type is used.

Syntax


oNode = artifactViewerControlID. addArtifactFactoryType (factoryClass)

Parameters

Parameter

Description

factoryClass

Required. Refers to the URL of the artifact factory class that is extended from the ArtifactFactoryType.


Return Value


It returns the object of the URL passed to the method if it is successfully added, otherwise it returns undefined.

Remarks


This method helps register artifact factory objects, which is the starting point for adding artifacts to the Artifact Viewer. This is shown in the below example.

You can use this method to add a factory type to Artifact Viewer.

Example


The following sample code demonstrates the use of this method.

//import ArtifactFactoryType into application
application.importType("wcp.library.util.ArtifactFactoryType");
//extend ArtifactFactoryType
Application.inherit(OrdersArtifactFactoryType, ArtifactFactoryType);
//make this function public. This step helps to make this function public and reuse across your applications.
setPublic(OrdersArtifactFactoryType, "com.cordys.orders");
function OrdersArtifactFactoryType()
{
}
/** this method returns type of an artifact  **/
OrdersArtifactFactoryType.prototype.getType = function()
{
	return "Orders";
}
/** this method helps to add behavior to each and every artifact **/
OrderArtifactFactory.prototype.addArtifactBehavior = function( applicationDefinition )
{
	return new OrdersArtifact( applicationDefinition );
}
function OrdersArtifact( applicationDefintiion )
{
}
//save above code snippet in separate .htm file in /Web/com/cordys/orders/ with name as ordersartifactfactory.htm.
//create object for OrdersArtifactFactoryType by passing URL to addArtifactFactoryType method
var  artifactFactoryObject = <<artifactviewerid>>. addArtifactFactoryType ( "com.cordys.orders.OrderArtifactFactory" );
//add the required artifacts